/** 
   Program to create a semaphore, taken from 
   www.ecst.csuchico.edu/~beej/guide/ipc/semaphores.html

   Modified by Dr. Roger Eggen on 9/27/00 in an effort to
   correct some errors in the program.
  */

#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>

int main(void)
{
    key_t key = 1234;
    int semid;
    /*union semun arg; */
	struct sembuf arg;

    /* grab the semaphore set created by seminit.c: */
    if ((semid = semget(key, 1, 0)) == -1) {
        printf("error in semget");
        exit(1);
    }

    /* remove it: */
    if (semctl(semid, 0, IPC_RMID, arg) == -1) {
        printf("error in semctl");
        exit(1);
    }

    return 0;
}
